@extends('Share/home')
<?php
$title='公司信息管理';
$nav_t='系统管理';
$nav_m='公司信息管理';
?>
@section('demand-body')
    <style>
        .clearfix:after {visibility:hidden;display:block;font-size:0;content:" ";clear:both;height:0;}
        .clearfix {zoom:1;}
        .Ly-ut-box{
            width:1280px;
            margin:0px auto;
            overflow:hidden;
            background-color:#ffffff;
        }
        .Ly-hd-box{
            width:1280px;
            margin:0 auto;
            background-color: #f6f6f6;
            border-top:2px solid #b2cff0;
            border-bottom:2px solid #b2cff0;
            position:relative;
            overflow:hidden;
        }
        .Ly-hd{
            width:1088px;
            height:40px;
            margin-left:96px;
            margin-top: 20px;
            border-bottom:2px solid #d5d5d5;
            overflow:hidden;
        }
        .Ly-hd-list{
            overflow:hidden;
        }
        .Ly-hd-list li{
            position:absolute;
            top:20px;
            width:70px;
            line-height: 40px;
            font-size:16px;
            font-family:'fzlth';
            color:#383838;
            text-align:center;
            cursor: pointer;
            border-bottom:2px solid #d5d5d5;
        }
        .Ly-hd-list .Ly-hd-list1{
            left:96px;
        }
        .Ly-hd-list .Ly-hd-list2{
            left:226px;
        }
        .Ly-hd-list .Ly-hd-list3{
            left:356px;
        }
 
        .Ly-gp-box{
            width:1088px;
            margin-left:96px;
            margin-top:30px;
            overflow: hidden;
        }
        .Ly-hd-list .Ly-lt-add{
            color:#00a7ea;
            border-bottom:2px solid #00a7ea;
        }
        .Ly-gp-le{
            display:none;
            overflow: hidden;
        }
        .Ly-gy-ln{
            margin-bottom:16px;
            overflow: hidden;
        }
        .Ly-gy-ln div{
            float:left;
            line-height: 32px;
        }
        .Ly-gy-ln .Ly-gy-lna{
            width:52px;
        }
        .Ly-gy-ln .M_downMenuW124{
            width: 135px;
        }
        .Ly-ad-btn{
            padding-left:52px;
            padding-bottom:32px;
            overflow: hidden;
        }
        .Ly-ad-btn .Ly_button5{
            float:left;
            margin-right:32px;
        }
        .Ly-ct-box{
            width:1088px;
            margin-left:96px;
            margin-top:32px;
            overflow:hidden;
        }
        .Ly-ct-tit,.Ly-ct-cet{
            float:left;
        }
        .Ly-ct-tit{
            width:54px;
            line-height: 40px;
            font-size:14px;
            color:#292929;
        }
        .Ly-ct-cet{
            width:864px;
        }
        .Ly-ct-list{
            overflow:hidden;
        }
        .Ly-ct-list li{
            float:left;
            padding-bottom: 24px;
            margin-right: 32px;
        }
        .Ly-eh-box{
            width:1030px;
            padding-left:54px;
            padding-bottom: 32px;
            overflow: hidden;
        }
        .Ly-eh-box .Ly_button{
            float:left;
            margin-right:32px;
        }
        .Ly-bn{
            width:96px;
            height: 32px;
            background: #f6f6f6;
        }
        .Ly-bn a{
            width:96px;
            height:32px;
            line-height:32px;
            color: #00a7ea;
        }
        .Ly-bn a:hover{
            color:#027aaa;
        }
        .Ly-dl-box{
            width:1280px;
            margin:0 auto;
            margin-top:34px;
        }
        .Ly-dl-list{
            width:1208px;
            background:#f6f6f6;
            height: 36px;
            padding-left: 72px;
            border-top:1px solid #dddddd;
            border-bottom:1px solid #dddddd;
            overflow: hidden;
        }
        .Ly-dl-list li{
            float:left;
            line-height: 36px;
            font-family:'fzlth';
            font-size:15px;
            color:#292929;
        }
        .Ly-dl-list .Ly-dl-list1,.Ly-ce-list .Ly-ce-list1{
            width:220px;
        }
        .Ly-dl-list .Ly-dl-list3,.Ly-ce-list .Ly-ce-list3{
            width:220px;
        }
        .Ly-dl-list .Ly-dl-list4,.Ly-ce-list .Ly-ce-list4{
            width:220px;
        }
        .Ly-dl-list .Ly-dl-list5,.Ly-ce-list .Ly-ce-list5{
            width:200px;
        }
        .Ly-dl-list .Ly-dl-list7,.Ly-ce-list .Ly-ce-list7{
            width:260px;
        }
        .Ly-ce-list{
            width:1208px;
            background:#ffffff;
            height: 46px;
            padding-left: 72px;
            border-bottom:1px solid #dddddd;
            overflow: hidden;
        }
        .Ly-ce-list li{
            float:left;
            font-size:12px;
            color:#666666;
            height:26px;
            font-family:'宋体';
            line-height: 46px;
        }
        .Ly-ry{
            font-size: 14px;
            color:#00a7ea;
            font-family:'fzlth';
            cursor: pointer;
        }
        .Ly-ry a{
            font-size: 14px;
            color:#00a7ea;
            font-family:'fzlth';
            cursor: pointer;
            text-decoration: none;
        }
        .Ly-ry a:hover{
            color:#027aaa;
        }
        .Ly-ce-list7 .Ly_button5 {
            float: left;
            margin-right: 32px;
            margin-top: 7px;
        }
        .Ly-dl-box .pageBox{
            margin-top:20px;
        }
        .action{
            color: red;
            margin-left: 10px;
        }
        .companyInfo-sel{
            width: 150px;
            height: 30px;
            line-height: 32px;
            font-size: 14px;
        }
        .companyInfo-modify-add{
            color: #00a7ea;
            float: left;
            cursor: pointer;
            display: block;
            font-size: 16px;
            line-height: 32px;
            text-align: center;
        }
    </style>
 
    <div class="demand-body">
        <div class="Ly-ut-box">
            <div class="Ly-hd-box">
                <div class="Ly-hd" id="anchor">
                    <ul class="Ly-hd-list">
                        <li class="Ly-hd-list1 J_companyInfo_hd_list Ly-lt-add">添加公司</li>
                        <li class="Ly-hd-list2 J_companyInfo_hd_list">添加部门</li>
                        <li class="Ly-hd-list3 J_companyInfo_hd_list">添加组</li>
                    </ul>
                </div>
                <div class="Ly-gp-box ">
 
                    <form id="form11" action="/system/companyInfo/create" method="post">
                        <input name="_token" type="hidden" value="{{csrf_token()}}">
                        <div class="Ly-gp-le Ly-gp-le1 J_companyInfo_gp" style="display:block">
                            <div class="Ly-gy-ln">
                                <div class="Ly-gy-lna">公司:</div>
                                <input type="hidden" name="Type" value="4" />
                                <input class="J_companyInfo_Id" type="hidden" name="id" value="" />
                                <input type="text" name="Name" maxlength="15" class="Ly_input J_companyInfo_blank"/><span class="action J_action"></span>
                            </div>
                        </div>
                    </form>
 
 
                    <form id="2" action="/system/companyInfo/create" method="post">
                        <div class="Ly-gp-le Ly-gp-le2 J_companyInfo_gp">
                            <input name="_token" type="hidden" value="{{csrf_token()}}"/>
                            <input type="hidden" name="Type" value="6"/>
                            <div class="Ly-gy-ln">
                                <div class="Ly-gy-lna">公司:</div>
                                <select name="ComId" class="companyInfo-sel j_com">
 
 
                                    @foreach($Com_list as $data)
                                        <option value="{{$data->id}}">{{$data->Name}}</option>
                                    @endforeach
                                </select>
                            </div>
                            <div class="Ly-gy-ln">
                                <div class="Ly-gy-lna">部门:</div>
                                <input class="J_companyInfo_Id" type="hidden" name="id" value="" />
                                <input type="text" name="Name" maxlength="15" class="Ly_input J_companyInfo_blank"/><span class="action J_action"></span>
                            </div>
                        </div>
                    </form>
                    <form id="3" action="/system/companyInfo/create" method="post">
                        <input name="_token" type="hidden" value="{{csrf_token()}}"/>
                        <input type="hidden" name="Type" value="8"/>
                        <div class="Ly-gp-le Ly-gp-le3 J_companyInfo_gp">
                            <div class="Ly-gy-ln">
                                <div class="Ly-gy-lna">公司:</div>
                                <select name="ComId" class="companyInfo-sel j_com">
                                    @if($Com_list!=NULL)
                                        @foreach($Com_list as $data)
                                            <option value="{{$data->id}}">{{$data->Name}}</option>
                                        @endforeach
                                    @else
                                    @endif
                                </select>
                            </div>
                            <div class="Ly-gy-ln">
                                <div class="Ly-gy-lna">部门:</div>
                                <select name="DepId" class="companyInfo-sel j_dep">
 
                                    @if($Com_list!=NULL)
                                        @foreach($Dep_list as $data)
                                            <option value="{{$data->id}}">{{$data->Name}}</option>
                                        @endforeach
                                    @else
                                    @endif
                                </select>
                            </div>
                            <div class="Ly-gy-ln">
                                <div class="Ly-gy-lna">组:</div>
                                <input class="J_companyInfo_Id" type="hidden" name="id" value="" />
                                <input type="text" name="Name" maxlength="15" class="Ly_input J_companyInfo_blank"/><span class="action J_action"></span>
                            </div>
                        </div>
 
                    </form>
                    @foreach ($errors->all() as $error)
                                        <p class="error">{{ $error }}</p>
                                        @endforeach
                    <div class="Ly-ad-btn">
                        <!--96*32 字符有间隙-->
                        <div class="Ly_button5 Ly_button Ly_button_bg1">
                            <input class="j_companyinfoman_sub" type="button" value="添加"/>
                        </div>
                    </div>
                </div>
            </div>
            <div class="Ly-dl-box">
                <ul class="Ly-dl-list">
                    <li class="Ly-dl-list3">公司</li>
                    <li class="Ly-dl-list4">部门</li>
                    <li class="Ly-dl-list5">组</li>
                    <li class="Ly-dl-list5">状态</li>
                    <li class="Ly-dl-list7">操作</li>
                </ul>
                @foreach($company_Tree as $data)
                    @if($data->Type=='4')
                        <ul class="Ly-ce-list" del="{{$data->Del}}" type="4">
 
                            <li class="Ly-ce-list3" value="{{$data->id}}">{{$data->Name}}</li>
                            <li class="Ly-ce-list4" value="{{$data->ComId}}"></li>
                            <li class="Ly-ce-list5" value="{{$data->DepId}}"></li>
 
                            @if($data->Del=='1')
                                <li class="Ly-ce-list5 J_companyInfo_status">启用</li>
                            @endif
                            @if($data->Del=='0')
                                <li class="Ly-ce-list5 J_companyInfo_status">已停用</li>
                            @endif
 
                            <li class="Ly-ce-list7">
                                <div class="Ly_button5 Ly_button Ly_button_bg1 J_companyInfo_modify"><a href="#anchor">修改</a></div>
                                <p class="Ly-ry">
                                    @if($data->Del=='1')
                                        <a class="J_companyInfo_disabled">停用</a>
                                    @endif
                                    @if($data->Del=='0')
                                        <a class="J_companyInfo_disabled">启用</a>
                                    @endif
                                </p>
                            </li>
                            <li class="J_companyInfo_action">
 
                            </li>
                        </ul>
                    @endif
 
                    @if($data->Type=='6')
                        <ul class="Ly-ce-list" del="{{$data->Del}}" type="6">
 
                            <li class="Ly-ce-list3" value="{{$data->id}}"></li>
                            <li class="Ly-ce-list4" value="{{$data->ComId}}">{{$data->Name}}</li>
                            <li class="Ly-ce-list5" value="{{$data->DepId}}"></li>
                            @if($data->Del=='1')
                                <li class="Ly-ce-list5 J_companyInfo_status">启用</li>
                            @endif
                            @if($data->Del=='0')
                                <li class="Ly-ce-list5 J_companyInfo_status">已停用</li>
                            @endif
                            <li class="Ly-ce-list7">
                                <div class="Ly_button5 Ly_button Ly_button_bg1 J_companyInfo_modify"><a href="#anchor">修改</a></div>
                                <p class="Ly-ry">
                                    @if($data->Del=='1')
                                        <a class="J_companyInfo_disabled">停用</a>
                                    @endif
                                    @if($data->Del=='0')
                                        <a class="J_companyInfo_disabled">启用</a>
                                    @endif
                                </p>
                            </li>
                            <li class="J_companyInfo_action">
 
                            </li>
                        </ul>
                    @endif
                    @if($data->Type=='8')
                        <ul class="Ly-ce-list" del="{{$data->Del}}" type="8">
 
                            <li class="Ly-ce-list3" value="{{$data->id}}"></li>
                            <li class="Ly-ce-list4" value="{{$data->ComId}}"></li>
                            <li class="Ly-ce-list5" value="{{$data->DepId}}">{{$data->Name}}</li>
                            @if($data->Del=='1')
                                <li class="Ly-ce-list5 J_companyInfo_status">启用</li>
                            @endif
                            @if($data->Del=='0')
                                <li class="Ly-ce-list5 J_companyInfo_status">已停用</li>
                            @endif
                            <li class="Ly-ce-list7">
                                <div class="Ly_button5 Ly_button Ly_button_bg1 J_companyInfo_modify"><a href="#anchor">修改</a></div>
                                <p class="Ly-ry">
                                    @if($data->Del=='1')
                                        <a class="J_companyInfo_disabled">停用</a>
                                    @endif
                                    @if($data->Del=='0')
                                        <a class="J_companyInfo_disabled">启用</a>
                                    @endif
                                </p>
                            </li>
                            <li class="J_companyInfo_action">
 
                            </li>
                        </ul>
                    @endif
 
 
                @endforeach
 
            </div>
 
        </div>
    </div>
    </div>
    <script>
        window.onload=function(){
            //弹窗
            var popup1=new popup({
                width:'400',
                height:'400',
                content:'<div class="pop-content"><h5>启用成功!</h5></div><div class="btn-box"><a class="btn-confirm J_companyInfo_start" id="pop_btn_confirm">确定</a></div>',
                hasMask: true,  //是否显示遮罩层
                enter:'spreadIn',
                leave:'spreadOut'
            });
            var popup2=new popup({
                width:'400',
                height:'400',
                content:'<div class="pop-content"><h5>停用成功!</h5></div><div class="btn-box"><a class="btn-confirm J_companyInfo_start" id="pop_btn_confirm">确定</a></div>',
                hasMask: true,  //是否显示遮罩层
                enter:'spreadIn',
                leave:'spreadOut'
            });
            var popup3=new popup({
                width:'400',
                height:'400',
                content:'<div class="pop-content"><h5>操作成功!</h5></div><div class="btn-box"><a class="btn-confirm J_companyInfo_start" id="pop_btn_confirm">确定</a></div>',
                hasMask: true,  //是否显示遮罩层
                enter:'spreadIn',
                leave:'spreadOut'
            });
            var popup4=new popup({
                width:'400',
                height:'400',
                content:'<div class="pop-content"><h5>该名字已存在!</h5></div><div class="btn-box"><a class="btn-confirm J_companyInfo_start" id="pop_btn_confirm">确定</a></div>',
                hasMask: true,  //是否显示遮罩层
                enter:'spreadIn',
                leave:'spreadOut'
            });
            var index=0;//当前在哪个tab
            //tab切换开始
            $('.J_companyInfo_action').text('');
            var tabSwitch=function(config){
                var _self = this;
                _self.config = $.extend({},tabSwitch.config,config);
            }
            tabSwitch.config={
                tabSwitch_number: ''
            };
            tabSwitch.prototype={
                _init: function(){
                    var _self = this;
                },
                _tabSwitch: function(){
                    var _self = this;
                    _self._switch();
                },
                _switch: function(){
                    var _self = this;
                    $('.J_companyInfo_hd_list').eq(_self.config.tabSwitch_number).addClass("Ly-lt-add").siblings().removeClass('Ly-lt-add');
                    $('.J_action').text('');
                    $('.J_companyInfo_gp').hide();
                    $('.J_companyInfo_gp').eq(_self.config.tabSwitch_number).show();
                    $('.j_companyinfoman_sub').val('添加');
                    $('.J_companyInfo_blank').val(' ');
                },
                _change: function(){
                    $('.j_companyinfoman_sub').val('修改');
                }
            };
 
            $('.J_companyInfo_hd_list').on('click',function(e){
                var target=e.target;
                $('.J_modify_add').remove();
                $('select option[class="J_companyInfo_smove"]').remove();
                index=$(target).index();
                var tabSwitch1=new tabSwitch({
                    tabSwitch_number: index
                });
                tabSwitch1._switch();
            })
 
            //form提交
            var formSub=function(config){
                var _self = this;
                _self.config = $.extend({},formSub.config,config);
            };
            formSub.config={
                reg: /^[\u4E00-\u9FA5]{1,15}$/,
                comVal: '',
                buVal: '',
                zuVal: '',
                comid: '',
                list: '',
                Dlist: ''
            };
            formSub.prototype={
                _init: function(){
                    var _self = this;
                    _self.config.comid=$('.j_com').eq(0).val();
                },
                _formSub: function(){
                    var _self = this;
                    _self._init();
                    _self._submit();
                    _self._cancel();
                    _self._getlist(_self.config.comid);
                    _self._selechange();
                },
                _testVal: function(inputval){
                    var _self=this;
                    if (inputval=='') {
                        $('.J_action').text('*输入框不能为空！');
                        return false;
                    }
                    else if (inputval.length>15) {
                        $('.J_action').text("*字符长度不能超过15个字符！");
                        return false;
                    }
                    else {
                        return true;
                    }
                },
                _submit: function(){
                    var _self=this;
                    $('.j_companyinfoman_sub').click(function(){
                        _self.config.comVal=$.trim($('.J_companyInfo_blank').eq(index).val());
                        if (_self._testVal(_self.config.comVal)==true) {
                            if($('.J_companyInfo_hd_list').eq(2).hasClass('Ly-lt-add')){
                                if($('.j_dep').children().length == 0){
                                    $('.J_action').text('*部门不能为空！');
                                }
                                else{
                                    $('form').eq(index).submit();
                                }
                            }
                            else{
                                $('form').eq(index).submit();
                            }
                        }
                    })
                    $(document).keydown(function(e){
                        if(e.keyCode == 13){
                            $('.j_companyinfoman_sub,.J_companyInfo_start').click();
                        }
                    })
                },
                _cancel: function(){
                    $('.j_companyinfoman_cans').click(function(){
                        $('.J_companyInfo_blank').val('');
                        $('.J_action').text('');
                    })
                },
                _getlist: function(comid){
                    var _self=this;
                    $.ajax({
                        url: 'select_List',
                        type: 'get',
                        data: {ComId:comid},
                        success:function(data){
                            _self.config.list=JSON.parse(data);
                            _self.config.Dlist=_self.config.list.data;
                            _self._append();
                        }
                    })
                },
                _append: function(){
                    var _self=this;
                    $('.j_dep').empty();
                    for (var i = 0; i <_self.config.Dlist.length; i++) {
                        $('.j_dep').append('<option value="'+_self.config.Dlist[i].id+'">'+_self.config.Dlist[i].Name+'</option>')
                    }
                },
                _selechange: function(){
                    var _self=this;
                    $('.j_com').on('change',function(){
                        _self.config.comid=$(this).val();
                        _self._getlist(_self.config.comid);
                    });
                    $('.J_companyInfo_hd_list').on('click',function(){
                        $('.j_com').change();
                    });
                }
            }
            
 
            var formSub1=new formSub({
            })
            formSub1._formSub();
 
            if('{{session('aa')}}'=='1'){
                popup3.create();
                $('.J_companyInfo_start').on('click',function(){
                    $('#pop_close').click();
                });
            }
            if('{{session('Name')}}'=='1'){
                var tabSwitch1=new tabSwitch({
                    tabSwitch_number: 0
                });
                tabSwitch1._switch();
                $('.J_action').text('*该公司名字已存在!');
            }
            if('{{session('Name')}}'=='2'){
                var tabSwitch1=new tabSwitch({
                    tabSwitch_number: 1
                });
                tabSwitch1._switch();
                $('.J_action').text('*该部门名字已存在!');
            }
            if('{{session('Name')}}'=='3'){
                var tabSwitch1=new tabSwitch({
                    tabSwitch_number: 2
                });
                tabSwitch1._switch();
                $('.J_action').text('*该组名字已存在!');
            }
            //修改
            $('.J_companyInfo_modify').on('click',function(e){
                var target=e.target;
                var parent=$(target).parent().parent().parent();
                var del=$(parent).attr('del');
                var type=$(parent).attr('type');
                var curid=$(parent).children().eq(0).val();
                var Cid=$(parent).children().eq(1).val();
                var Did=$(parent).children().eq(2).val();
                $('.J_modify_add').remove();
                $('.j_companyinfoman_sub').parent().parent().append('<p class="companyInfo-modify-add J_modify_add">添加</p>');
                $('.J_modify_add').on('click',function(){
                    $(this).remove();
                    $('.j_companyinfoman_sub').val('添加');
                    $('select option[class="J_companyInfo_smove"]').remove();
                    $('.J_companyInfo_blank').val('');
                    $('.J_companyInfo_Id').val('');
                    var depid=$('.j_com').val();
                    $.ajax({
                        url: 'select_List',
                        type: 'get',
                        data: {ComId:depid},
                        success:function(data){
                            var list=JSON.parse(data);
                            var Dlist=list.data;
                            $('.j_dep').empty();
                            for (var i = 0; i <Dlist.length; i++) {
                                $('.j_dep').append('<option value="'+Dlist[i].id+'">'+Dlist[i].Name+'</option>')
                            }
                        }
                    })
                })
                if($(parent).find('li').eq(0).text()!=''){
                    index=0;
                    var tabSwitch2=new tabSwitch({
                        tabSwitch_number: index
                    });
                    tabSwitch2._switch();
                    tabSwitch2._change();
                    $('.J_companyInfo_blank').val($(parent).find('li').eq(0).text());
                    $('.J_companyInfo_Id').eq(0).val(curid);
                }
                else if($(parent).find('li').eq(1).text()!=''){
                    index=1;
                    var tabSwitch3=new tabSwitch({
                        tabSwitch_number: index
                    });
                    tabSwitch3._switch();
                    tabSwitch3._change();
                    $('.J_companyInfo_blank').val($(parent).find('li').eq(1).text());
                    $('.J_companyInfo_Id').eq(1).val(curid);
                    if(del==0){
                        $.ajax({
                            url: 'edit',
                            type: 'get',
                            data: {Id:curid,Type:type},
                            success:function(data){
                                var d=JSON.parse(data);
                                var dd=d.data;
                                var dC=d.ComId;
                                $('.j_com').append('<option class="J_companyInfo_smove" value="'+dC[0].id+'">'+dC[0].Name+'</option>')
                                $('.j_com').val(Cid);
                            }
                        })
                    }
                    else{
                        $('.j_com').val(Cid);
                    }
                }
                else if($(parent).find('li').eq(2).text()!=''){
                    index=2;
                    var tabSwitch4=new tabSwitch({
                        tabSwitch_number: index
                    });
                    tabSwitch4._switch();
                    tabSwitch4._change();
                    $('.J_companyInfo_blank').val($(parent).find('li').eq(2).text());
                    $('.J_companyInfo_Id').eq(2).val(curid);
                    if(del==0){
                        $.ajax({
                            url: 'edit',
                            type: 'get',
                            data: {Id:curid,Type:type},
                            success:function(data){
                                var d=JSON.parse(data);
                                var dd=d.data;
                                var dC=d.ComId;
                                var dD=d.DepId;
                                $('.j_com').append('<option class="J_companyInfo_smove" value="'+dC[0].id+'">'+dC[0].Name+'</option>')
                                $('.j_com').val(Cid);
                                $('.j_dep').empty();
                                $('.j_dep').append('<option class="J_companyInfo_smove" value="'+dD[0].id+'">'+dD[0].Name+'</option>')
                                $('.j_dep').val(Did);
                            }
                        })
                    }
                    else{
                        $('.j_com').val(Cid);
                        $.ajax({
                            url: 'select_List',
                            type: 'get',
                            data: {ComId:Cid},
                            success:function(data){
                                var list=JSON.parse(data);
                                var Dlist=list.data;
                                $('.j_dep').empty();
                                for (var i = 0; i <Dlist.length; i++) {
                                    $('.j_dep').append('<option value="'+Dlist[i].id+'">'+Dlist[i].Name+'</option>')
                                }
                                $('.j_dep').val(Did);
                            }
                        })
                    }
 
                }
            })
 
            //修改操作成功
            var modifySuccess='{{session('aa')}}';
 
            //停用,启用
            $('.J_companyInfo_disabled').on('click',function(e){
                var target=e.target;
                var parent=$(target).parent().parent().parent();
                var del=$(parent).attr('del');
                var id=$(parent).children().eq(0).val();
                var type=$(parent).attr('type');
                var D='';
                $.ajax({
                    url: 'restore_disable',
                    type: 'get',
                    data: {
                        id:id,
                        del:del,
                        Type:type
                    },
                    success:function(data){
                        D=JSON.parse(data);
                        var com = D.data;
                        var str = '';
                        if(D.Success=='true'){
                            for(var i = 0;i < com.length;i++){
                                str = str + '<option value="'+ com[i].id +'">'+ com[i].Name +'</option>';
                            }
                            $('.j_com').empty();
                            $('.j_com').append(str);
                            formSub1._selechange();
                            $('.j_com').change();
                            if(del==0){
                                popup1.create();
                                $('.J_companyInfo_start,#pop_close').on('click',function(){
                                    $(parent).attr('del','1');
                                    $(parent).find('.J_companyInfo_status').text('启用');
                                    $(parent).find('.J_companyInfo_disabled').text('停用');
                                    $('.J_companyInfo_action').text('');
                                });
                            }
                            else{
                                popup2.create();
                                $('.J_companyInfo_start,#pop_close').on('click',function(){
                                    if(type == '8'){
                                        $(parent).attr('del','0');
                                        $(parent).find('.J_companyInfo_status').text('已停用');
                                        $(parent).find('.J_companyInfo_disabled').text('启用');
                                    }
                                    else if(type == '6'){
                                        $(parent).attr('del','0');
                                        $(parent).find('.J_companyInfo_status').text('已停用');
                                        $(parent).find('.J_companyInfo_disabled').text('启用');
                                        $('.Ly-ce-list').each(function(i,v){
                                            if($(v).find('.Ly-ce-list5').attr('value') == id){
                                                $(v).attr('del','0');
                                                $(v).find('.J_companyInfo_status').text('已停用');
                                                $(v).find('.J_companyInfo_disabled').text('启用');
                                            }
                                        })
                                    }
                                    else if(type == '4'){
                                        $(parent).attr('del','0');
                                        $(parent).find('.J_companyInfo_status').text('已停用');
                                        $(parent).find('.J_companyInfo_disabled').text('启用');
                                        $('.Ly-ce-list').each(function(i,v){
                                            if($(v).find('.Ly-ce-list4').attr('value') == id){
                                                $(v).attr('del','0');
                                                $(v).find('.J_companyInfo_status').text('已停用');
                                                $(v).find('.J_companyInfo_disabled').text('启用');
                                            }
                                        })
                                    }
                                });
                            }
                        }
                        else{
                            $(parent).find('.J_companyInfo_action').text('不能启用');
                        }
                    }
                })
            });
 
        }
    </script>
    
@endsection
